import React, { PureComponent } from 'react';
import {connect} from 'dva'
import {Icon} from 'antd'
import VideoUpload from './video'
import FileUpload from './file'
import HomePageIntroVideo from './homePageIntroVideo'
const Components ={
  video: VideoUpload,
  file: FileUpload,
  homePageIntroVideo: HomePageIntroVideo,
}
@connect(state => ({
}))
class UploadFiles extends PureComponent {
  state = {

  }
  componentWillMount() {
    this.getQiniucloud()
  }

  getQiniucloud = () => {
    this.props.dispatch({type: 'qiniucloud/fetchUptoken'});
  }
  render() {
    let { label, name, props, onChange } = this.props
    // console.log('this.props: ', this.props)

    let CurrentComponent = Components[name]
    return (
      <div style={{padding: '10px 20px'}}>
        <div>{label}</div>
        <CurrentComponent {...props} onChange={onChange}/>
      </div>
    );
  }
}

export default UploadFiles




